﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewDesigner.aspx.cs" Inherits="WebQueryRole.ViewDesigner" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="styles/style.css" rel="Stylesheet" type="text/css" />    
    <% if (createViewSuccess && !String.IsNullOrEmpty(Request["inputViewName"]))
       {
           Response.Write("<META HTTP-EQUIV=\"refresh\" CONTENT=\"3;URL=Default.aspx?sql_code=SELECT * FROM " + Request["inputViewName"] + "\">");
       } %>
    <script type="text/javascript">
        //
        function onSubmitUpdateQuery() {
            var inputVN = document.getElementById('inputViewName');

            if (inputVN != null && inputVN != 'undefined') {
                document.getElementById('hiddenViewName').value = inputVN.value;
            }            
            return true;
        }
    </script>
    <style type="text/css">
    .fs_wrapper 
    {
        
    }
    
    fieldset 
    {
        margin 10px;
        padding: 5px;        
        border-color: #edf;    
        width: -moz-fit-content;    
    }
    
    </style>
</head>
<body>    
        <div runat="server" id="divReport"></div>
        
        <% 
            // if we we did not create a view here, lets show the view creation interface
            if (!createViewSuccess)
            {           
                 %>
            <form id="sqlQueryForm" method="get" onsubmit="onSubmitUpdateQuery()">
                <input type="hidden" id="hiddenViewName" runat="server" />
                <div style="margin: 0 auto; width:90%">
                    <textarea class="sql_query" style="width: 98%;" id="textAreaSelectQuery" rows="9" runat="server"></textarea>
                    <div style="margin: 0px auto;"><input type="submit" value="Update View Wizard" /></div>                    
                </div>                
            </form>
            
            
            <% 
            // sometimes we get here with no SQL statement, lets not show a blank query
            if (HasViewWizard)
            {                    
                   %>
            <form id="serverForm" runat="server" method="post">            
            
            <div class="fs_wrapper">        
                <fieldset>
                    <legend>Create Table Wizard</legend>
                    <div>
                        <label>Table Name</label>
                        <input type="text" runat="server" id="inputViewName" />       
                    </div>
                    <asp:PlaceHolder ID="phViewColumns" runat="server" />
                    <div style="margin: 0px auto;"><input type="submit" value="Save Table" /></div>
                </fieldset>
            </div>            
            </form>                                    
        <% 
            }
        }
         %>    
</body>
</html>
